<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Manager Home Page</title>

<script language="JavaScript" type="text/javascript">
function getauction(auctionid)
{
  document.testform.auctionId.value = auctionid;
  document.testform.submit();
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery_tabs.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function() {$('#tabs_news').tabs({ fxFade: true, fxSpeed: 'fast' });});
</script>
<script language="javascript">
function deleteRecord(id){
		window.open('http://localhost:8085/CSE305/userdelete.jsp?id='+id,'mywindow','width=300, height=200,toolbar=no,resizable=yes,menubar=no');
}
</script>
<script language="javascript">
function editRecord(id){
    window.open('http://localhost:8085/CSE305/edit.jsp?id='+id,'mywindow','width=300, height=200,toolbar=no,resizable=yes,menubar=no');
}
</script>

</head>
<body>
	<div class="main">
		<div class="header">
			<div class="resize">
				<div class="logo">
					<img src="images/logo.png" alt="picture" width="171" height="42"
						border="0" /></a>
				</div>
				<div class="clr"></div>
			</div>
			<div class="clr"></div>
		</div>
		<div class="slider_resize">
			<div class="clr"></div>
		</div>
		<div class="FBG">
			<div class="clr"></div>
		</div>
		<div class="body">
			<div class="resize">
				<div class="left">

					<%
  		/////////////////////////////////////////////////////////////////////
  		// PUT EMPLOYEE'S DATA CODE HERE!!!!!                              //
  		/////////////////////////////////////////////////////////////////////
  		%>

					<h2><%=session.getValue("login")%>'s Data
					</h2>
					<table id="EmployeeData" width="550">
						<tr>
							<td>First Name</td>
							<td>Last Name</td>
							<td>SSN</td>
							<td>Hourly Rate</td>
						</tr>
						<% 
        
        String username = ""+session.getValue("login");
  			java.sql.Connection conn=null;
			try 
			{
            	Class.forName((String)session.getValue("mysJDBCDriver")).newInstance();
    			java.util.Properties sysprops=System.getProperties();
    			sysprops.put("user",(String)session.getValue("mysUserID"));
    			sysprops.put("password",(String)session.getValue("mysPassword"));
        
				//connect to the database
            			conn=java.sql.DriverManager.getConnection((String)session.getValue("mysURL"),sysprops);
            			System.out.println("Connected successfully to database using JConnect");
            
            			java.sql.Statement stmt1=conn.createStatement();
        
					java.sql.ResultSet rs = stmt1.executeQuery("select * from Employee_SELF_DATA where Employee_Self_DATA.SSN = '"+username+"'");
%>
						<form name="testform" method="get" action="AuctionInfo.jsp">
							<input type="hidden" name="auctionId" />
							<%
      	  
      	  while(rs.next())
      	  {
%>
							<tr>
								<td><span style="font-size: 10pt"><%=rs.getString(1)%></span></td>
								<td><span style="font-size: 10pt"><%=rs.getString(2)%></span></td>
								<td><span style="font-size: 10pt"><%=rs.getString(3)%></span></td>
								<td><span style="font-size: 10pt"><%=rs.getString(4)%></span></td>
							</tr>
							<%     		
        	}
  			} catch(Exception e)
			{
				e.printStackTrace();
				out.print(e.toString());
			}
			finally{
			
				try{conn.close();}catch(Exception ee){};
			}

  %>
						</form>
					</table>

					<%
  		/////////////////////////////////////////////////////////////////////
  		// PUT THE VIEW ALL EMPLOYEE DATA RECOMMENDED CODE Below HERE!!!!! //
  		/////////////////////////////////////////////////////////////////////
  		%>
					<p></p>
					<h2>All Employee Data</h2>
					<table id="PurchaseHistory" width="655">
						<tr>
							<td>First Name</td>
							<td>Last Name</td>
							<td>Address</td>
							<td>City</td>
							<td>State</td>
							<td>Zip</td>
							<td>Phone</td>
							<td>SSN</td>
							<td>StartDate</td>
							<td>Position</td>
						</tr>
						<% 
        
        	username = ""+session.getValue("login");
  			conn=null;
			try 
			{
            	Class.forName((String)session.getValue("mysJDBCDriver")).newInstance();
    			java.util.Properties sysprops=System.getProperties();
    			sysprops.put("user",(String)session.getValue("mysUserID"));
    			sysprops.put("password",(String)session.getValue("mysPassword"));
        
				//connect to the database
            			conn=java.sql.DriverManager.getConnection((String)session.getValue("mysURL"),sysprops);
            			System.out.println("Connected successfully to database using JConnect");
            
            			java.sql.Statement stmt1=conn.createStatement();
        
					    java.sql.ResultSet rs = stmt1.executeQuery("select * from Employee_ALL_DATA");
%>
						<form name="testform" method="get" action="userdelete.jsp">
							<input type="hidden" name="target" value="EmployeeData">
								<%
      	  
      	  while(rs.next())
      	  {
%>
								<tr>
									<td><span style="font-size: 8pt"><%=rs.getString(1)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(2)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(3)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(4)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(5)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(6)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(7)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(8)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(9)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(10)%></span></td>
									<td>
										<div align="center">
											<a href="ManagerHomePage.jsp"
												onclick="deleteRecord(<%=rs.getString(11)%>);">Delete</a>
										</div>
									</td>
								</tr> <%     		
        	}
  			} catch(Exception e)
			{
				e.printStackTrace();
				out.print(e.toString());
			}
			finally{
			
				try{conn.close();}catch(Exception ee){};
			}

  %>
							
						</form>
					</table>

					<%
  		/////////////////////////////////////////////////////////////////////
  		// PUT THE VIEW ALL CUSTOMER DATA CODE Below HERE!!!!! //
  		/////////////////////////////////////////////////////////////////////
  		%>
					<p></p>
					<h2>All Customer Data</h2>
					<table id="CustomerData" width="655">
						<tr>
							<td>Username</td>
							<td>First Name</td>
							<td>Last Name</td>
							<td>Address</td>
							<td>City</td>
							<td>State</td>
							<td>Zipcode</td>
							<td>Phone</td>
							<td>Email</td>
							<td>Credit Card</td>

						</tr>
						<% 
        
        	username = ""+session.getValue("login");
  			conn=null;
			try 
			{
            	Class.forName((String)session.getValue("mysJDBCDriver")).newInstance();
    			java.util.Properties sysprops=System.getProperties();
    			sysprops.put("user",(String)session.getValue("mysUserID"));
    			sysprops.put("password",(String)session.getValue("mysPassword"));
        
				//connect to the database
            			conn=java.sql.DriverManager.getConnection((String)session.getValue("mysURL"),sysprops);
            			System.out.println("Connected successfully to database using JConnect");
            
            			java.sql.Statement stmt1=conn.createStatement();
        
					    java.sql.ResultSet rs = stmt1.executeQuery("select * from Customer_ALL_DATA");
%>
						<form name="testform" method="get" action="userdelete.jsp">
							<input type="hidden" name="target" value="CustomerData">
								<%
      	  
      	  while(rs.next())
      	  {
%>
								<tr>
									<td><span style="font-size: 8pt"><%=rs.getString(3)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(1)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(2)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(4)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(5)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(6)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(7)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(8)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(9)%></span></td>
									<td><span style="font-size: 8pt"><%=rs.getString(10)%></span></td>
									<td>
										<div align="center">
											<a href="ManagerHomePage.jsp"
												onclick="deleteRecord(<%=rs.getString(11)%>);">Delete</a></div><td>
	<!--  Could not figure out how to finish editing because of the joint tables, so commented out feature 										
									<td><div align="center"><a href="ManagerHomePage.jsp" onclick="editRecord(<%=rs.getString(11)%>);">Edit</a></div></td>
								</tr> 
								
	-->	
<%     		
        	}
  			} catch(Exception e)
			{
				e.printStackTrace();
				out.print(e.toString());
			}
			finally{
			
				try{conn.close();}catch(Exception ee){};
			}

  %>
							
						</form>
					</table>


					<%
  		/////////////////////////////////////////////////////////////////////
  		// PUT THE VIEW ALL EMPLOYEE DATA RECOMMENDED CODE Below HERE!!!!! //
  		/////////////////////////////////////////////////////////////////////
  		%>
					<p></p>
					<h2>All Employee Data</h2>
					<p>vvv Assuming this part is being worked on below vvv</p>
					<table id="PurchaseHistory" width="655">
						<tr>
							<td>User Name</td>
							<td>First Name</td>
							<td>Last Name</td>
							<td>Address</td>
							<td>City</td>
							<td>State</td>
							<td>Zip</td>
							<td>Phone</td>
							<td>Card#</td>
							<td>Email</td>
							<td>Rating</td>
						</tr>
						<% 
        
        	username = ""+session.getValue("login");
  			conn=null;
			try 
			{
            	Class.forName((String)session.getValue("mysJDBCDriver")).newInstance();
    			java.util.Properties sysprops=System.getProperties();
    			sysprops.put("user",(String)session.getValue("mysUserID"));
    			sysprops.put("password",(String)session.getValue("mysPassword"));
        
				//connect to the database
            			conn=java.sql.DriverManager.getConnection((String)session.getValue("mysURL"),sysprops);
            			System.out.println("Connected successfully to database using JConnect");
            
            			java.sql.Statement stmt1=conn.createStatement();
        
					java.sql.ResultSet rs = stmt1.executeQuery("select * from Customer_ALL_DATA");
%>
						<form name="testform" method="get" action="AuctionInfo.jsp">
							<input type="hidden" name="auctionId" />
							<%
      	  
      	  while(rs.next())
      	  {
%>
							<tr>
								<td><span style="font-size: 8pt"><%=rs.getString(1)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(2)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(3)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(4)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(5)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(6)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(7)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(8)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(9)%></span></td>
								<td><span style="font-size: 8pt"><%=rs.getString(10)%></span></td>
							</tr>
							<%     		
        	}
  			} catch(Exception e)
			{
				e.printStackTrace();
				out.print(e.toString());
			}
			finally{
			
				try{conn.close();}catch(Exception ee){};
			}

  %>
						</form>
					</table>

				</div>
				<div class="right">
					<h2>
						<a href="CustomerRegistration.htm"><FONT SIZE="4">Add
								New Customers</FONT></a>
					</h2>
					<h2>
						<a href="EmployeeRegistration.htm"><FONT SIZE="4">Add
								New Employees</FONT></a>
					</h2>
					</br> <input id="Button1" type="button" value="Logout"
						onclick="window.open('index.htm','_self');" />

				</div>
				<div class="clr"></div>
			</div>
		</div>
		<div class="footer">
			<div class="resize" style="background: #141414;">
				<p class="leftt">
					Created by: Andrew Gratta, Sarah Jordan, and Kevin O'Flaherty<br />
					<p class="rightt">
						<span class="leftt">Copyright. All Rights Reserved</span>
					</p>
					<p class="rightt">Developed for CSE305 at Stony Brook
						University</p>
					<div class="clr"></div>
			</div>
		</div>
	</div>
</html>
</body>